package com.wc.alorithm_luogu.P2141;

import java.util.HashMap;
import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/4/21 14:37
 * @description https://www.luogu.com.cn/problem/P2141
 * 珠心算测验
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // key 表示原来的数,value 表示位置
        HashMap<Integer, Integer> map = new HashMap<>();
        // 存放答案
        int ans = 0;

        int n = sc.nextInt();

        int[] array = new int[n];

        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
            map.put(array[i], i);
        }
        // 排序为了方便计算
//        Arrays.sort(array);
        int target;

        for (int i = n - 1; i >= 0; i--) {
            target = array[i];
            for (int j = 0; j < n; j++) {
                if (map.containsKey(target - array[j])) {
                    if (map.get(target-array[j])!=j) {
                        ans++;
                        break;
                    }
                }
            }
        }

        System.out.println(ans);
    }
}
